import React from 'react';
import { Button } from 'antd';

import { useRequest, defaultFormatResult } from '@/hooks';
import { TalkResult as Result } from '@/pages/OnboardAndLeave/LeaveManagement/Talk/containers';
import { getConclusion } from '@/pages/OnboardAndLeave/LeaveManagement/service';
import { TopSection, getTalkLinkHandler } from './TalkProcess';

const TalkResult = ({ data = {}, title }) => {
    const { id, interviewRefCode } = data;
    const { data: conclusionData = {} } = useRequest(() => getConclusion(id, interviewRefCode), {
        ready: !!id,
        ...defaultFormatResult
    });

    const extendTop = (
        <div style={{ borderBottom: '1px solid #E8E8E8', marginBottom: 10, paddingBottom: 10 }}>
            <TopSection data={data} />
        </div>
    );

    const extendBottom = (
        <div style={{ paddingTop: 16 }}>
            <Button
                onClick={() => {
                    getTalkLinkHandler(data)('/office/personnelManagement/onboardAndLeave/leaveManagement/talk/detail');
                }}
                style={{ borderRadius: 16, marginBottom: 10 }}
            >
                查看详情
            </Button>
        </div>
    );

    return <Result
        data={conclusionData}
        extendTop={extendTop}
        extendBottom={extendBottom}
        title={title}
        onlyConclusionWhenAgree
    />;
};

export default TalkResult;
